package com.jsh.erp.cloud.api;

import com.jsh.erp.datasource.entities.User;
import com.jsh.erp.service.functions.FunctionService;
import com.jsh.erp.service.user.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/api/user")
public class UserApi {
    @Autowired
    private UserService userService;
    @Autowired
    private FunctionService functionService;

    @GetMapping("/getUserId")
    public Long getUserId(HttpServletRequest request) throws Exception {
        return userService.getUserId(request);
    }

    @GetMapping("/{id}")
    public User getUser(@PathVariable Long id) throws Exception {
        return userService.getUser(id);
    }

    @GetMapping("/getCurrentUser")
    public User getCurrentUser() throws Exception {
        return userService.getCurrentUser();
    }

}
